﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using System.Reflection;

namespace InstallerGUI2
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        static Assembly dllResolve(Object sender, ResolveEventArgs args)
        {

            String resourceName = "InstallerGUI2." +

               new AssemblyName(args.Name).Name + ".dll";
            try
            {
                if (manifestResourceNames == null) manifestResourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
                if (manifestResourceNames.Contains(resourceName))
                {
                    using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
                    {

                        Byte[] assemblyData = new Byte[stream.Length];

                        stream.Read(assemblyData, 0, assemblyData.Length);

                        return Assembly.Load(assemblyData);

                    }
                }
            }
            catch { }
            return null;
        }
        static string[] manifestResourceNames = null;
        static App()
        {
            AppDomain.CurrentDomain.AssemblyResolve += dllResolve;
        }
    }
}
